package com.ruoyi.auto.api.factory;

import com.ruoyi.auto.api.RemoteAutoPublishProductService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.gather.api.domain.dto.AeAutoProductDto;
import com.ruoyi.gather.api.domain.dto.TaskStatusDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;


/**
 * 自动化上架服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteAutoPublishProductFallbackFactory implements FallbackFactory<RemoteAutoPublishProductService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteAutoPublishProductFallbackFactory.class);

    @Override
    public  RemoteAutoPublishProductService create(Throwable throwable)
    {
        log.error("更新上架计划状态调用失败:{}", throwable.getMessage());
        return new RemoteAutoPublishProductService()
        {
            @Override
            public R<Object> updatePublishTaskStatusByCurrentTime(String id)
            {
                return R.fail("未查找到可执行上架计划:" + throwable.getMessage());
            }

            @Override
            public R<String> runPublishProductTask(String id) {
                return R.fail("上架任务启动失败:" + throwable.getMessage());
            }

            @Override
            public R<Object> updateTaskStatus(TaskStatusDto taskStatusDto) {
                return R.fail("修改任务状态/备注失败:" + throwable.getMessage());
            }

            @Override
            public R<Object> runAutoPublishProject() {
                return R.fail("创建上架任务失败");
            }

            @Override
            public R<Object> deleteTortListByCollectProductId(Long collectProductId) {
                return R.fail("删除失败:" + throwable.getMessage());
            }

            @Override
            public R<Object> restartPublishProductProjectJob() {
                return R.fail("重启上架执行计划:" + throwable.getMessage());
            }

            @Override
            public R<Object> setCommissionAgainOne() {
                return R.fail("重新设置联盟折扣失败");
            }

            @Override
            public R<Object> setCommissionAgainTwo() {
                return R.fail("重新设置联盟折扣失败");
            }

            @Override
            public R<Object> runNotCreatePulishProductProjectJob() {
                return R.fail("重建上架计划失败");
            }

            @Override
            public R<Object> processingProjectGroupAndDiscount() {
                return R.fail("调用爬虫创建活动");
            }

        };
    }
}
